package id.co.gomobile.assessment

class Preference {
	
	// associations
	Test test

	int timeout = 15
	int maxQuestions = 30
	int maxQuestionsPerPage = 15
	boolean forceSubmitOnTimeout = true
	
	def totalTimeout = {
		int numPage = maxQuestions / maxQuestionsPerPage
		return Math.ceil(numPage).asType(int) * timeout
	}
	
    static constraints = {
		timeout(blank: false)
		maxQuestions(blank: false)
		maxQuestionsPerPage(min: 1, blank: false)
		forceSubmitOnTimeout()
    }
}
